package com.example.testproject.activity

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.testproject.R
import kotlinx.android.synthetic.main.activity_result_api_second.*

/**
 *
 * @ClassName: ResultApiSecondActivity
 * @Author: android 超级兵
 * @CreateDate: 11/3/21$ 9:30 AM$
 * TODO
 */
class ResultApiSecondActivity : AppCompatActivity() {
    companion object {
        const val SECOND_TRANSMIT_DATA = "second_transmit_data"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_result_api_second)

        tvResult.text = intent.getStringExtra(ResultApiFirstActivity.TRANSMIT_DATA)
            ?: "我是second页面,没有接收到first的数据啊"


        btSecond.setOnClickListener {
            val intent = Intent()
            intent.putExtra(SECOND_TRANSMIT_DATA, "我是第二个页面的数据啊")
            setResult(ResultApiFirstActivity.RESULT_CODE, intent)
            finish()
        }
    }
}